package galatea;

import java.awt.Color;

import javax.swing.BorderFactory;
import javax.swing.DefaultListModel;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListSelectionModel;
import javax.swing.border.TitledBorder;

public class ObjectList extends JList{
	DefaultListModel listModel;
	
	ObjectList(DefaultListModel newList, String title){
		listModel = new DefaultListModel();
		
		this.setModel(listModel);
		
		this.setCellRenderer(new ListRenderer());
		
		this.setBorder(BorderFactory.createTitledBorder(title));
		
		this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		this.setSelectedIndex(0);
		this.setVisibleRowCount(5);
	}
	
	void addObject(ListObject newObj){
		listModel.addElement(newObj);
	}
	
	void changeList(DefaultListModel newList, String listName){
		this.setModel(newList);
		//listModel = newList;
		((TitledBorder)(this.getBorder())).setTitle(listName);
	}
}
